
export function initOption({color,dataList}) {
    let options = {
        title: [
            {
                text: '总数',
                x: 'center',
                top: '53%',
                textStyle: {
                    fontSize: 15,
                    fontWeight: '300',
                    color: 'rgba(255, 255, 255, 0.3)',
                }
            },
            {
                text: '12019',
                x: 'center',
                top: '42%',
                textStyle: {
                    fontSize: 18,
                    color: '#fff',
                }
            }
        ],
        tooltip: {
            trigger: 'item',
            formatter: '{a} <br/>{b}: {c} ({d}%)',
            textStyle: {
                fontSize: 10
            },
        },
        color,
        legend: {
            orient: 'vertical',
            left: '51%',
            bottom: 0,
            data:['类别一', '类别二', '类别三', '类别四'],
            textStyle: {
                color: '#fff'
            },
            icon:'circle',
            itemGap: 10,
            itemWidth: 10,
            itemHeight: 10,
            align: 'auto',
            textStyle: {
                color: '#fff',
            },
            selectedMode:false,
        },
        angleAxis: {
            max: 100,
            show: false,
            startAngle: -90,
        },
        radiusAxis: {
            type: 'category',
            data: ['类别一', '类别二', '类别三', '类别四'],
            show: true,
            axisLabel: {
                show:false
            },
            axisLine: {
                show: false,
            },
            axisTick: {
                show: false
            }
        },
        polar: {
            radius: ['40%', '100%'],
            center: ['50%', '50%']
        },
        color: ["#32b16c", "#d14a63", "#1a8577", "#d59344"],
        series: [],
    }

    let obj = {
        type: 'bar',
        roundCap: true,
        coordinateSystem: "polar",
        stack: 'a',
        barWidth: 10,
        showBackground: true,
        backgroundStyle: {
            color: '#46494b'
        },
    }
    dataList.forEach(item => {
        options.series.push(Object.assign({...obj }, { ...item }));
    });
    return options;
}


export function handlerOptions(chart, newConfig) {
    if (newConfig && (Object.keys(newConfig).length !== 0)) {
        chart.setOption({ ...newConfig }, false);
        console.log(chart.getOption());
    }
}